﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace LyyCMS.Migrations
{
    public partial class add_article_category : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ArticleCategory",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(nullable: false),
                    ParentId = table.Column<int>(nullable: false),
                    SortId = table.Column<int>(nullable: false),
                    FatherId = table.Column<int>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ArticleCategory", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ArticleCategory_ArticleCategory_FatherId",
                        column: x => x.FatherId,
                        principalTable: "ArticleCategory",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Article",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(nullable: false),
                    ArticleCategoryId = table.Column<int>(nullable: false),
                    Click = table.Column<int>(nullable: false),
                    ImgUrl = table.Column<string>(nullable: true),
                    Url = table.Column<string>(nullable: true),
                    Summary = table.Column<string>(nullable: true),
                    Content = table.Column<string>(type: "text", nullable: true),
                    SortId = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Article", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Article_ArticleCategory_ArticleCategoryId",
                        column: x => x.ArticleCategoryId,
                        principalTable: "ArticleCategory",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.UpdateData(
                table: "Blogs",
                keyColumn: "Id",
                keyValue: 1,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 401, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Blogs",
                keyColumn: "Id",
                keyValue: 2,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 401, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 1,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 401, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 2,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 402, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 3,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 402, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 4,
                column: "Create_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 402, DateTimeKind.Local).AddTicks(9022));

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                column: "Crete_At",
                value: new DateTime(2019, 10, 22, 11, 25, 21, 398, DateTimeKind.Local).AddTicks(9020));

            migrationBuilder.CreateIndex(
                name: "IX_Article_ArticleCategoryId",
                table: "Article",
                column: "ArticleCategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_ArticleCategory_FatherId",
                table: "ArticleCategory",
                column: "FatherId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Article");

            migrationBuilder.DropTable(
                name: "ArticleCategory");

            migrationBuilder.UpdateData(
                table: "Blogs",
                keyColumn: "Id",
                keyValue: 1,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 904, DateTimeKind.Local).AddTicks(771));

            migrationBuilder.UpdateData(
                table: "Blogs",
                keyColumn: "Id",
                keyValue: 2,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 904, DateTimeKind.Local).AddTicks(771));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 1,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 905, DateTimeKind.Local).AddTicks(772));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 2,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 905, DateTimeKind.Local).AddTicks(772));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 3,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 905, DateTimeKind.Local).AddTicks(772));

            migrationBuilder.UpdateData(
                table: "Comments",
                keyColumn: "Id",
                keyValue: 4,
                column: "Create_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 905, DateTimeKind.Local).AddTicks(772));

            migrationBuilder.UpdateData(
                table: "Users",
                keyColumn: "Id",
                keyValue: 1,
                column: "Crete_At",
                value: new DateTime(2019, 10, 16, 18, 2, 55, 899, DateTimeKind.Local).AddTicks(769));
        }
    }
}
